using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace net_work.Config.DataBaseConfig.System;

/// <summary>
/// 文件实体配置类
/// </summary>
public class FileInfoEntityTypeConfiguration : IEntityTypeConfiguration<Data.Entity.System.MyFile>
{
    public void Configure(EntityTypeBuilder<Data.Entity.System.MyFile> builder)
    {
        builder.ToTable("sys_file");

        builder.HasKey(f => f.Id);

        // 配置字段名映射
        builder.Property(f => f.Id).HasColumnName("file_id");
        builder.Property(f => f.FilePath).HasColumnName("file_path").IsRequired().HasMaxLength(512);
        builder.Property(f => f.FileName).HasColumnName("file_name").IsRequired().HasMaxLength(128);
        builder.Property(f => f.FileType).HasColumnName("file_type").IsRequired().HasMaxLength(128);
        builder.Property(f => f.FileUseId).HasColumnName("file_use_id").IsRequired();

        builder.Property(f => f.CreatedBy).HasColumnName("create_by").IsRequired().HasMaxLength(64);
        builder.Property(f => f.CreatedTime).HasColumnName("create_time").IsRequired();
        builder.Property(f => f.UpdatedBy).HasColumnName("update_by").IsRequired().HasMaxLength(64);
        builder.Property(f => f.UpdatedTime).HasColumnName("update_time").IsRequired();
        builder.Property(f => f.Remark).HasColumnName("remark").HasMaxLength(256);
        builder.Property(f => f.DelFlag).HasColumnName("del_flag").HasDefaultValue('0');
    }
}